package com.hao.study.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hao.study.entity.Resume;
import com.hao.study.service.ResumeService;
import com.hao.study.mapper.ResumeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
* @author Administrator
* @description 针对表【b_resume】的数据库操作Service实现
* @createDate 2024-06-12 13:18:37
*/
@Service
public class ResumeServiceImpl extends ServiceImpl<ResumeMapper, Resume>
    implements ResumeService {
    @Autowired
    ResumeMapper mapper;

    @Override
    public PageInfo<Resume> getList(Integer pageNum, Integer pageSize, String keyWord) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<Resume> queryWrapper=new QueryWrapper<>();
        if (!StringUtils.isEmpty(keyWord)){
            queryWrapper.like("name",keyWord);
        }
        List<Resume> list = mapper.selectList(queryWrapper);
        return PageInfo.of(list);
    }

    @Override
    public void createResume(Resume resume) {
        System.out.println(resume);
        mapper.insert(resume);
    }

    @Override
    public void deleteById(String id) {
        mapper.deleteById(id);
    }

    @Override
    public void updateResume(Resume resume) {
        mapper.updateById(resume);
    }

    @Override
    public Resume getDetail(String userId) {
        QueryWrapper<Resume> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        return mapper.selectOne(queryWrapper);
    }
}




